<!--
    JBoss, Home of Professional Open Source
    Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
    contributors by the @authors tag. See the copyright.txt in the
    distribution for a full listing of individual contributors.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>temperature-converter</title>
</head>

<body>

    <h1>JBoss Temperature Converter Service</h1>
    <p>Enter the temperature you wish to convert; optionally, type the scale as well ('C' for Celsius, 'F' for Fahrenheit).</p>
    <div id="container">
        <h:form id="convertForm">
            <h:panelGrid columns="2">
                <h:outputLabel for="radio">Scale (default):</h:outputLabel>
                <h:selectOneRadio value="#{temperatureConverter.defaultScale}" id="radio" converter="#{scaleConverter}">
                    <f:selectItems value="#{scaleConverter.scales}" var="scale" itemLabel="#{scale.symbol}" itemValue="#{scale}" />
                </h:selectOneRadio>
                <h:outputLabel for="sourceTemperature">Temperature:</h:outputLabel>
                <h:inputText id="sourceTemperature" value="#{temperatureConverter.sourceTemperature}" />
                <h:commandButton id="convert" value="Convert" action="#{temperatureConverter.convert}" />
                <h:messages />
            </h:panelGrid>
        </h:form>
        <h:form id="response">
            <h:panelGrid columns="2">
                <h:outputLabel for="temperature">Converts to:</h:outputLabel>
                <h:outputLabel id="temperature" value="#{temperatureConverter.temperature}" />
            </h:panelGrid>
        </h:form>
        <hr />
        <p>How the conversion works:</p>
        <p>The temperature-string is parsed with a regular expression that expects a floating point number followed optionally by a temperature unit ('C' or 'F', case-insensitive).
            If the temperature unit is missing, the default scale (given by the radio button) is used.</p>
        <p>An 'error message' will be issued if it cannot convert the temperature-string, and '0.0 Err' will be returned as
            the result.</p>
        <p>Both input temperature and the result are truncated at 3 decimal places only.</p>

    </div>

</body>
</html>
